package com.sy.service;

import com.sy.dto.JsonResult;
import com.sy.entity.Blog;
import com.sy.entity.Category;
import com.sy.entity.CategoryCollection;
import org.omg.PortableInterceptor.Interceptor;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Description:
 * date: 2021/1/15 18:55
 *
 * @author:
 * @since JDK 1.8
 */
public interface BlogService {
    /**
     * 根据博客分类查询博客
     * @param id
     * @return
     */
    JsonResult getNavBlogInfos(Integer id);


    @Transactional(
            //当出现指定类型异常或其子类异常的时候进行回滚，默认对所有的运行时异常进行回滚
            rollbackFor = Exception.class,
            //当出现什么异常的时候不进行回滚
            //noRollbackFor =
            //传播行为
            propagation = Propagation.REQUIRED,
            //隔离级别
            isolation = Isolation.READ_COMMITTED,
            //超时时间
            timeout = -1,
            //只读性
            readOnly = false
    )
    JsonResult loadBlog(Blog blog, List<Category> categories);

    /**
     * 获得博客详情页该博客的相关信息
     * @param blogId
     * @return
     */
    JsonResult getDetailBlogInfo(Integer blogId);

    /**
     * 根据用户id获取该用户的最热博客,根据浏览次数获取
     * @param userId
     * @return
     */
    JsonResult getHotestBlogOverview(Integer userId);

    JsonResult  getHotestBlog();

    JsonResult  getCollectCountBlog();

    JsonResult getThumbsBlog();

    JsonResult getBlogsByCategoryId(Integer categoryId);

    JsonResult getUserByBlogId(Integer userId);
}
